<html>
<head><meta charset="utf-8"><title>Where is info on the Rust calling convention? · t-lang/wg-unsafe-code-guidelines · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/index.html">t-lang/wg-unsafe-code-guidelines</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html">Where is info on the Rust calling convention?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="184137641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184137641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184137641">(Dec 23 2019 at 22:48)</a>:</h4>
<p>I know that the Rust ABI isn't stable, but where can I find out what it's actually doing in a particular version? Like 1.40 or whatever specific version. Obviously it must do something.</p>
<p>How much does it adapt to the local target definition? In LLVM, if you define a custom target there's a default data layout that LLVM has that you can override. If you give a custom data layout will Rust play along?</p>



<a name="184141068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184141068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184141068">(Dec 24 2019 at 00:07)</a>:</h4>
<p>I don't think we document this at all, but generally speaking, src/librustc_codegen_{ssa,llvm} and librustc_mir is probably where to look.</p>



<a name="184375192"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184375192" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184375192">(Dec 28 2019 at 13:27)</a>:</h4>
<p>You also want to look at librustc/.../layout.ty</p>



<a name="184375195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184375195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184375195">(Dec 28 2019 at 13:27)</a>:</h4>
<p>Since that's where the <code>Layout</code> and <code>Abi</code>'s are tied together</p>



<a name="184375236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184375236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> gnzlbg <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184375236">(Dec 28 2019 at 13:28)</a>:</h4>
<p>e.g. <code>Abi::ScalarPair</code> means that the Rust calling convention for scalar pairs is different than for other <code>repr(rust)</code> aggregates</p>



<a name="184381199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184381199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184381199">(Dec 28 2019 at 16:23)</a>:</h4>
<p>Particularly I want to know how the stack works.</p>
<p>ARM eabi has an 8byte aligned stack, and the default LLVM data layout also has an 8 aligned stack, but I would like a 4 aligned stack on a particular embedded program where I know that I've compiled 100% of the code. And I want to know if I can just change the setting in LLVM and have Rust go with it.</p>



<a name="184381319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184381319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184381319">(Dec 28 2019 at 16:26)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> If LLVM keeps values 8 aligned when they are need it, then telling LLVM to align stacks to 4 should be fine. Rust doesn't manipulate the stack itself. Instead it uses <code>alloca</code>.</p>



<a name="184381327"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where%20is%20info%20on%20the%20Rust%20calling%20convention%3F/near/184381327" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/136281-t-lang/wg-unsafe-code-guidelines/topic/Where.20is.20info.20on.20the.20Rust.20calling.20convention.3F.html#184381327">(Dec 28 2019 at 16:26)</a>:</h4>
<p>excellent!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>